﻿using DapperExtensions;
using DapperExtensions.Mapper;
using DapperExtensions.Sql;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Nova.Data
{
    public class DbFactory
    {
        public static Database CreateConnection(string strCon, DatabaseType databaseType = DatabaseType.SqlServer)
        {
            Database database = null;
            switch (databaseType)
            {
                case DatabaseType.SqlServer:
                    var sqlconn = new SqlConnection(strCon);
                    var sqlconfig = new DapperExtensionsConfiguration(typeof(AutoClassMapper<>), new List<Assembly>(), new SqlServerDialect());
                    var sqlGenerator = new SqlGeneratorImpl(sqlconfig);
                    database = new Database(sqlconn, sqlGenerator);
                    sqlconn.Close();
                    break;
                case DatabaseType.Oracle:
                    break;
            }
            return database;
        }

        public enum DatabaseType
        {
            SqlServer,
            MySql,
            Oracle,
        }
    }
}
